<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button data-toggle-id="abc">email</button>

    <div id="abc">hello box</div>

    <h2 data-toggle-id="efg">hello</h2>
    <p id="efg">this is p1 this is p1 this is p1 this is p1</p>
    <script>
      /*
        1. 找id等于toggle-id元素
        2. 此元素如果显示则隐藏，如果隐藏则显示
      */
      // 复用
      document.onclick = function (e) {
        const toggleId = e.target.dataset.toggleId;
        if (toggleId) {
          const el = document.getElementById(toggleId);
          el.hidden = !el.hidden;
        }
      };
    </script>
  </body>
</html>
